module.exports = function ($scope, $state, $resource, $modal, toaster ){
    $scope.tour_list = function (pageNo){
        var para = {
            'pageNo': pageNo || $scope.currentPage,
            'pageSize': $scope.itemsPerPage,
            'title':$scope.info.searchtitle,
            'tour_type':$scope.info.tour_type,
            'managger_name':$scope.info.searchmanagger_name,
            'managger_card_no':$scope.info.searchmanagger_card_no,
            'managger_mobile':$scope.info.searchmanagger_mobile
        }
        
          $scope.info = [];
    
          $resource('/api/as/goc/tourbase/findRuleList', {}, {}).save(para,function (res) {
        
            if (res.errcode !== 0) {
              alert("数据获取失败");
              return;
            }
            $scope.list = res.data.results;
            console.log("获取游团列表"+res.data.results);
            

          });
    } 
   
    init();
    //初始化列表
    function init(){
        $scope.currentPage = 1;		//当前页码
        $scope.itemsPerPage = 10;	//每页显示几条
        $scope.searchform = {};
        $scope.tour_list();
    }

     //查看
     $scope.gettournfo = function(code) {
      console.log(code);
        var modalInstance = $modal.open({
            template: require('../views/tourinfo.html'),
            controller: 'tourinfo',
            size: 'lg',
            resolve: {
                code : function () {
                    return code;
                }
            }
        });
        
        //关闭模态框刷新页面
        modalInstance.result.then(function() {
            init();
        });
    }
    //发起申请
    $scope.updateup = function(code) {
        if(confirm('确认提交申请吗?')){
          $resource('/api/ac/goc/irTourService/updateup', {}, {}).save({'code': code}, function(res){
            if (res.errcode === 0) {
              toaster.success({title: '', body: '申请成功'});
              init();
            }else{
              toaster.error({title: '', body: res.errmsg});
            }
          });
        }
      }
    //撤回申请
    $scope.updatedown = function(code) {
        if(confirm('确认撤回申请吗?')){
          $resource('/api/ac/goc/irTourService/updatedown', {}, {}).save({'code': code}, function(res){
            if (res.errcode === 0) {
              toaster.success({title: '', body: '撤回成功'});
              init();
            }else{
              toaster.error({title: '', body: res.errmsg});
            }
          });
        }
      }
    //删除
    $scope.delete = function(code) {
      if(confirm('确认删除吗?')){
        $resource('/api/ac/goc/irTourService/delete', {}, {}).save({'code': code}, function(res){
          if (res.errcode === 0) {
            toaster.success({title: '', body: '删除成功'});
            init();
          }else{
            toaster.error({title: '', body: res.errmsg});
          }
        });
      }
    }

     //修改基本信息
     $scope.savetourinfo = function(info) {
        
            var modalInstance = $modal.open({
            template: require('../views/tourgroupsub.html'),
            controller: 'tourgroupsub',
            size: 'lg',
            resolve: {
                item : function () {
                    return info;
                },
                flag : function () {
                    return info == 1;
                }
            }
          });
          
          //关闭模态框刷新页面
          modalInstance.result.then(function() {
              init();
          });
      }
    //游团团期信息
    $scope.savetourbase = function(info) {
    
        var modalInstance = $modal.open({
            template: require('../views/tourbase.html'),
            controller: 'tourbase',
            size: 'lg',
            resolve: {
                item : function () {
                    return info;
                },
                flag : function () {
                    return info == 1;
                }
            }
        });
          
        //关闭模态框刷新页面
        modalInstance.result.then(function() {
            init();
        });
      }
    
    //游团团期信息
    $scope.savetourprice = function(info) {
        console.log(info);
        var modalInstance = $modal.open({
            template: require('../views/tourprice.html'),
            controller: 'tourprice',
            size: 'lg',
            resolve: {
                item : function () {
                    return info;
                },
                flag : function () {
                    return info == 1;
                }
            }
        });
            
        //关闭模态框刷新页面
        modalInstance.result.then(function() {
            init();
        });
    }
      


};